<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login Page</title>
    <style>
        /* 全局样式 */
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f5f5f5;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        /* 登录框容器 */
        .login-container {
            width: 350px;
            background-color: #fff;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            text-align: center;
        }

        .login-container h2 {
            margin-bottom: 20px;
            color: #333;
        }

        /* 输入框样式 */
        .input-group {
            margin-bottom: 20px;
            text-align: left;
        }

        .input-group label {
            display: block;
            margin-bottom: 5px;
            font-size: 14px;
            color: #666;
        }

        .input-group input {
            width: 100%;
            padding: 10px;
            font-size: 14px;
            border: 1px solid #ccc;
            border-radius: 5px;
            outline: none;
        }

        .input-group input:focus {
            border-color: #007BFF;
        }

        /* 颜色选择器样式 */
        .color-picker {
            margin-top: 10px;
        }

        /* 登录按钮样式 */
        .login-btn {
            width: 100%;
            padding: 10px;
            background-color: #007BFF;
            border: none;
            border-radius: 5px;
            color: white;
            font-size: 16px;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .login-btn:hover {
            background-color: #0056b3;
        }

        /* 额外链接样式 */
        .extra-links {
            margin-top: 15px;
            font-size: 12px;
        }

        .extra-links a {
            color: #007BFF;
            text-decoration: none;
        }

        .extra-links a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <h2>设置面板</h2>
        <form id="login-form" action="login_process" method="post">
            <!-- 用户名输入框 -->
            <div class="input-group">
                <label for="username">用户名:</label>
                <input type="text" id="username" name="username" placeholder="请输入你的昵称" required>
            </div>
            <!-- 颜色选择器 -->
            <div class="input-group color-picker">
                <label for="color">设置消息颜色:</label>
                <input type="color" id="color" name="color">
            </div>
            <!-- 登录按钮 -->
            <button type="submit" class="login-btn">保存设置</button>
        </form>
    </div>

    <script>
        const urlParams = new URLSearchParams(window.location.search);
        const username = urlParams.get('username');
        const color = urlParams.get('userColor');
        if(username){
            document.getElementById('username').value = username;
        }
        if(color){
            document.getElementById('color').value = color;
        }
        // 获取登录表单
        document.getElementById('login-form').addEventListener('submit', function(event) {
            event.preventDefault(); // 阻止表单默认提交行为

            // 获取输入的用户名和选择的颜色
            var username = document.getElementById('username').value;
            var color = document.getElementById('color').value;

            // 跳转到目标页面，并传递账号信息和颜色作为 URL 参数
            window.location.href = '/client.html?username=' + encodeURIComponent(username) + '&color=' + encodeURIComponent(color);
        });
    </script>
</body>
</html>
